<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>发布帖子页面</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">

    <script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>


    <style>
        body {
            background-color: pink;
            color: white;

        }

        .row h1 {
            color: white;
        }

        .control-label {
            color: pink;
        }

        #heading {
            background-color: white;
            color: pink;
        }

        .panel-default {
            border-color: pink;
        }

        input[type='checkbox'] {
            position: relative;
            top: 7px;
            left: -10px;
        }

    </style>

</head>
<body>
<header>
    <div class="container" style="margin-left: 350px">
        <h1>
            <b>发布博客</b>
        </h1>
    </div>
</header>
<div class="container">
        <div class="col-md-offset-2 col-md-8">
            <!--登录面板-->
            <div class="panel panel-default">
                <!--面板主体-->
                <div class="panel-body">
                    <!--登录表单-->
                    <form style="color: black" id="myform" class="form-horizontal" role="form"
                          action="loginaction" enctype="multipart/form-data">
                        <!--标题-->
                        <div class="form-group">
                            <label for="title" class="col-md-2 control-label">标题</label>
                            <div class="col-md-8">
                                <input type="text"
                                       class="form-control" id="title" name="title"
                                       placeholder="请输入作品标题">
                            </div>
                        </div>
                        <!--作者-->
                        <div class="form-group">
                            <label for="author" class="col-md-2 control-label">作者</label>
                            <div class="col-md-8">
                                <input type="text"
                                       class="form-control" id="author" name="author"
                                       placeholder="请输入作者名字">
                            </div>
                        </div>
                        <!--简介-->
                        <div class="form-group">
                            <label  class="col-md-2 control-label">帖子正文</label><!--for="intro"-->
                            <div class="col-md-8" colspan="2">
                                <div id="div1">
                                    <p>写点啥...</p>
                                </div>
                            </div>
                        </div>
                        <!--标签-->
                        <div class="form-group">
                            <label  class="col-md-2 control-label">请至少选择一个标签</label>
                            <select multip name="" id="n" style="padding: 5px 10px;margin-left: 15px">
                                <option value="">---请选择标签---</option>
                                <option value="1">1</option>
                                <option value="2">2</option>
                                <option value="3">3</option>
                                <option value="4">4</option>
                            </select>
                        </div>
                        <!--上传-->
                        <div class="form-group">
                            <label  class="col-md-2 control-label">选择文件</label>
                            <div class="col-md-8">
                                <input type="file" name="picFile">
                            </div>
                        </div>

                        <!--发布按钮-->
                        <div class="form-group">
                            <div class="col-md-offset-2 col-md-10">
                                <button type="button" class="btn btn-default sublogin"
                                        @click="upload()">发布作品</button>
                                <span></span>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
</div>
<!--网页页脚-->
<footer>
    <div class="container">
        <div class="text-center">
            <a target="_blank" href="/index.html">迪迪巴士博客</a>
            版权所有
        </div>
    </div>
</footer>
</body>
<!--引入vue-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<!--引入axios-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- 引入 wangEditor.min.js -->
<script type="text/javascript">
    const E = window.wangEditor
    const editor = new E('#div1')
    // 或者 const editor = new E( document.getElementById('div1') )
    editor.create()
</script>
<script>
    let vm=new Vue({
        el:"form",
        data:{},
        methods:{
            send:function () {//点击事件
                //得到form表单数据
                let data =new FormData(document.querySelector("form"));
                axios.post("/detail/send",data).then(function (response) {
                    if (response.data==1){
                        alert("发布成功!")
                        location.href="/";//回到首页
                    }else {
                        alert("请先登录!");
                        location.href="/";//显示登录的页面
                    }
                })
            }
        }
    })
</script>
<script src="js/selectMultip.js"></script>
<script>
    selectMultip.register();
</script>
</html>